home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 170 < prev    next >
Internet Message Format  |  1996-08-06  |  4KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c
  4. Subject: Re: atexit() and return from main()
  5. Date: 23 Jan 1996 15:51:57 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan23085157@qcd.lanl.gov>
  8. References: <4dhfja$j50@fg70.rz.uni-karlsruhe.de> <4diicg$i9e@lyra.csx.cam.ac.uk>
  9.     <TANMOY.96Jan22084309@qcd.lanl.gov>
  10.     <DLMLL6.A0H@ukpsshp1.serigate.philips.nl>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: baynes@ukpsshp1.serigate.philips.nl's message of Tue, 23 Jan 1996 08:43:54 GMT
  15.  
  16. --text follows this line--
  17. In article <DLMLL6.A0H@ukpsshp1.serigate.philips.nl>
  18. baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes: 
  19. <snip>
  20.    :    :    main() calls setjmp() and then calls exit().  An atexit() function
  21.    :    :    calls longjmp() and returns to main().  This repeats (or does it?)
  22.  
  23.    :    : Neither of these is permitted in any sense that I understand!
  24.    :    : 7.10.4.3: If more than one call to the exit function is executed by
  25.    :    : a program, the behaviour is undefined. No `permission by omission'
  26.    :    : that I can see.
  27.  
  28.    :    In this example what happens if no second call to exit is been made (after
  29.    :    longjumping back to main the program does not attempt to call exit again -
  30.    :    instead it keeps executing indefinately)?
  31.  
  32.    : I don't understand the question: are you asking what happens if a
  33.    : program keeps executing indefinitely? Well, it just keeps executing
  34.    : indefinitely. After that infinite period, the rest of the exit
  35.    : processing happens and a return status is indicated to the rts.
  36.  
  37.    The question I am asking is if:
  38.        main() calls setjmp() and then calls exit().  An atexit() function
  39.        calls longjmp() and returns to main().  main() then continues to
  40.        execute other code. Is the execution of this code defined behaviour
  41.        (so long as no attempt is made to exit again)?
  42.  
  43. Okay, let me be more precise: what in the standard suggests that this
  44. is undefined behaviour? It is difficult to have an opinion about
  45. something when I do not even see the counterpoint.
  46.  
  47. (Note: nothing in the standard implies that anything takes a finite
  48. non-zero amount of time. A program continuing `for ever' after a call
  49. to exit should therefore be perfectly fine. I do not see any reason to
  50. think otherwise.)
  51.  
  52. <snip>
  53.    A related question - does undefined behaviour invalidate (make undefined) all 
  54.    defined behaviour that has gone before? If so does this mean that any program 
  55.    that does not exit() or return from main have any defined behaviour?
  56.  
  57. I again feel that the question is wrongly phrased. Once a program uses
  58. a construct that leads to undefined behaviour, the international
  59. standard imposes no constraints on how the _program_ is translated and
  60. executed. (except, due to TC1 I believe, some possible diagnostics
  61. continue to be required) There is no concept that I can find in the
  62. standard that justifies the concept of `before' or `after' an
  63. `undefined behaviour' occurs.
  64.  
  65. The last question I can't parse. But I think that the question you
  66. want to discuss is whether a program that doesn't terminate falls in
  67. the category of programs using constructs with `undefined behaviur'. I
  68. fail to see what construct that may be.
  69.  
  70. Cheers
  71. Tanmoy
  72. --
  73. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  74. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  75. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  76. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  77. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  78. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  79.